/**
 * This file was created by Andrew Darrohn
 * StartScreen for use in SpaceTrader
 * @author Andrew Darrohn
 */

import java.awt.Polygon;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * contains all the code for the is the 
 * start screen
 * @author Andrew Darrohn
 * @version 1.0
 */
public class StartScreen extends JPanel implements MouseListener {

    /**
     * new game polygon x values
     */
    private final int[] newGamePolyX = new int[] { 220, 358, 358, 220 }; // $codepro.audit.disable numericLiterals
    
    /**
     * new game polygon y values
     */
    private final int[] newGamePolyY = new int[] { 262, 262, 286, 286 }; // $codepro.audit.disable numericLiterals
    
    /**
     * load game polygon x values
     */
    private final int[] loadGamePolyX = new int[] { 210, 367, 367, 210 }; // $codepro.audit.disable numericLiterals
    
    /**
     * load game polygon y values
     */
    private final int[] loadGamePolyY = new int[] { 286, 286, 310, 310 }; // $codepro.audit.disable numericLiterals
    
    /**
     * creates the polygon
     */
    private final Polygon newGamePolygon;
    
    /**
     * creates the polygon
     */
    private final Polygon loadGamePolygon;

    /**
     * Create the panel.
     */
    public StartScreen() { // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.constructorsOnlyInvokeFinalMethods
	newGamePolygon = new Polygon(newGamePolyX, newGamePolyY,
		newGamePolyX.length);
	loadGamePolygon = new Polygon(loadGamePolyX, loadGamePolyY,
		loadGamePolyX.length);
	setLayout(null);

	final JLabel lblNewLabel = new JLabel("New label");
	lblNewLabel.setIcon(new ImageIcon("imgs//startScreen.png"));
	lblNewLabel.setBounds(0, 0, 568, 408); // $codepro.audit.disable numericLiterals
	add(lblNewLabel);

	addMouseListener(this);

    }

    /**
     * the click handler
     * @param e MouseEvent
    
     * @see java.awt.event.MouseListener#mouseClicked(MouseEvent) */
    @Override
    public void mouseClicked(MouseEvent e) {
	if (newGamePolygon.contains(e.getPoint())) {
	    System.out.println("Clicked New Game");
	    Game.InitConfigScreen.showScreen((JPanel) Game.NewPlayerScreen);
	}

	if (loadGamePolygon.contains(e.getPoint())) {

	    System.out.println("Clicked Load Game");

	    final SaveLoad load = new SaveLoad();
	    final SaveLoad loadData = SaveLoad.load(Game.SaveFilename);

	    if (loadData != null) {
		Game.Space = loadData.space; // $codepro.audit.disable assignmentToNonFinalStatic
		Game.Player = loadData.player; // $codepro.audit.disable assignmentToNonFinalStatic

		System.out.println(Game.Player);
		System.out.println(Game.Player.getName());
		System.out.println(Game.Player.getShip().getName());

		Game.InitConfigScreen
			.showScreen(Game.GameScreen = new GameScreen( // $codepro.audit.disable assignmentToNonFinalStatic
				Game.Space, Game.Player));
	    }

	}
	System.out.println("");
    }

    /**
     * auto gen'd dont need
    
     * @param e MouseEvent
     * @see java.awt.event.MouseListener#mouseEntered(MouseEvent) */
    @Override
    public void mouseEntered(MouseEvent e) {
	// TODO Auto-generated method stub
	System.out.println("");

    }

    /**
     * auto gen'd dont need
     * @param e MouseEvent
     * @see java.awt.event.MouseListener#mouseExited(MouseEvent) */
    @Override
    public void mouseExited(MouseEvent e) {
	// TODO Auto-generated method stub
	System.out.println("");
    }

    /**
     * auto gen'd dont need
     * @param e MouseEvent
    
     * @see java.awt.event.MouseListener#mousePressed(MouseEvent) */
    @Override
    public void mousePressed(MouseEvent e) {
	// TODO Auto-generated method stub
	System.out.println("");
    }
    
    /**
     * auto gen'd dont need
     * @param e MouseEvent
    
     * @see java.awt.event.MouseListener#mouseReleased(MouseEvent) */
    @Override
    public void mouseReleased(MouseEvent e) {
	// TODO Auto-generated method stub
	System.out.println("");
    }

}
